% examples for the pdf document

-compile({parse_transform, cctrans}).
-module(democlient).
-include("class1.hrl").
-include("class2.hrl").
-export([demo/0, demo2/0]).
demo() ->
    % create an instance of the class
    A1 = #class1{field2 = hello},
    % call method1 of the instance
    {A2, X1} = {A1}:method1(5),
    % call method2 of the instance
    X2 = {A2}:method2(b),
    X1+X2.

demo2() ->
    A = #class2{},
    
    obj#class1{field2 = Field2, field3 = Field3} = A.

demo3({_, obj#class1{field1 = a, field2 = [Field2|_]}}) when Field2 > 2 ->
    Field2;
demo3({X, _}) ->
    X.


demo4(A, Param) ->
    obj#class1{field1 = X} = {A}:method2(obj#class2{field2 = {a, X}} = Param).


demo5(A, B) ->
    {A}#class1{field1 = a, field2 = {B}#class1{field2 = a} }.

demo6(X) ->
    obj#class1{field2 = a, field3 = b, field1 = obj#class1{field2 = A, field3 = {x, y}}} = X,
    A.
